#include<iostream>
using namespace std;
const int N = 1e6 + 10;
int arr[N];
bool st[N];
int n;
void fun()
{
	int cnt = 0;
	for (int i = 2; i <= N; i++) {
		if (!st[i]) {
			arr[i] = ++cnt;
			for (int j = i * 2; j <= N; j += i) {
				st[j] = 1;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		if (!arr[i]) {
			arr[i] = arr[i - 1];
		}
	}
}
int main()
{
	int t;
	cin >> t;
	fun();
	for (int i = 1; i <= 10; i++) {
		cout << arr[i] << " ";
	}
	cout << endl;
	while (t--) {
		cin >> n;
		cout << arr[n] << endl;
	}
	return 0;
}